﻿using Abp.Authorization;
using Mt.Site.Application.Dto;
using Mt.Site.Core.Authorization;
using Mt.Site.Core.BadWordsFilters;
using System.Threading.Tasks;

namespace Mt.Site.Application.Caching
{
    [AbpAuthorize(AppPermissions.Pages_BadWords)]
    public class BadWordsAppService : MtSiteAppServiceBase, IBadWordsAppService
    {
        private readonly IBadWordFilterManager _badWordFilterManager;

        public BadWordsAppService(
            IBadWordFilterManager badWordFilterManager)
        {
            _badWordFilterManager = badWordFilterManager;
        }

        public async Task UpdateOrCreateConfigFileAsync(ConfigFileDto input)
        {
            await _badWordFilterManager.SaveNewWordsText(input.Content);
        }

        public async Task<string> GetConfigFileContentAsync()
        {
            return await _badWordFilterManager.GetWordsTextAsync();
        }
    }
}